home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / updates / update27.zoo / pml / diffs
Encoding:
Text File  |  1992-12-28  |  8.2 KB  |  321 lines

  1. ===================================================================
  2. RCS file: /net/acae127/home/bammi/etc/src/master/atari/pml/pmlsrc/Changelog,v
  3. retrieving revision 1.17
  4. diff -c -r1.17 Changelog
  5. *** 1.17    1992/08/14 15:18:43
  6. --- Changelog    1992/12/28 08:11:47
  7. ***************
  8. *** 293,295 ****
  9. --- 293,300 ----
  10.       add target for ident.o
  11.   
  12.   ---------------------------- Patchlevel 19 ------------------------------
  13. + sqrt.c:: Michal Jaegermann
  14. +     major hacks. see the comments at the top.
  15. + ---------------------------- Patchlevel 20 ------------------------------
  16. ===================================================================
  17. RCS file: /net/acae127/home/bammi/etc/src/master/atari/pml/pmlsrc/PatchLev.h,v
  18. retrieving revision 1.16
  19. diff -c -r1.16 PatchLev.h
  20. *** 1.16    1992/08/14 15:20:26
  21. --- PatchLev.h    1992/12/28 08:11:48
  22. ***************
  23. *** 1,4 ****
  24. ! #define    PatchLevel "19"
  25.   
  26.   /*
  27.    *
  28. --- 1,4 ----
  29. ! #define    PatchLevel "20"
  30.   
  31.   /*
  32.    *
  33. ===================================================================
  34. RCS file: /net/acae127/home/bammi/etc/src/master/atari/pml/pmlsrc/math.h,v
  35. retrieving revision 1.14
  36. diff -c -r1.14 math.h
  37. *** 1.14    1992/08/14 15:18:43
  38. --- math.h    1992/12/28 08:11:51
  39. ***************
  40. *** 46,51 ****
  41. --- 46,57 ----
  42.   extern "C" {
  43.   #endif
  44.   
  45. + #ifdef __TURBOC__
  46. + #include <tcmath.h>
  47. + #else
  48.   #ifndef __STRICT_ANSI__
  49.   /*
  50.    *    Create the type "COMPLEX".  This is an obvious extension that I
  51. ***************
  52. *** 76,94 ****
  53.       double        retval; /* val to return */
  54.   };
  55.   
  56. ! #define M_LN2        0.69314718055994530942
  57. ! #define M_PI        3.14159265358979323846
  58. ! #define M_SQRT2        1.41421356237309504880
  59. ! #define M_E        2.7182818284590452354
  60. ! #define M_LOG2E        1.4426950408889634074
  61. ! #define M_LOG10E    0.43429448190325182765
  62. ! #define M_LN10        2.30258509299404568402
  63. ! #define M_PI_2        1.57079632679489661923
  64. ! #define M_PI_4        0.78539816339744830962
  65. ! #define M_1_PI        0.31830988618379067154
  66. ! #define M_2_PI        0.63661977236758134308
  67. ! #define M_2_SQRTPI    1.12837916709551257390
  68. ! #define M_SQRT1_2    0.70710678118654752440
  69.   
  70.   #endif /* __STRICT_ANSI__ */
  71.   
  72. --- 82,100 ----
  73.       double        retval; /* val to return */
  74.   };
  75.   
  76. ! #define M_LN2                0.69314718055994530942
  77. ! #define M_PI         3.14159265358979323846
  78. ! #define M_SQRT2              1.41421356237309504880
  79. ! #define M_E          2.7182818284590452354
  80. ! #define M_LOG2E              1.4426950408889634074
  81. ! #define M_LOG10E     0.43429448190325182765
  82. ! #define M_LN10               2.30258509299404568402
  83. ! #define M_PI_2               1.57079632679489661923
  84. ! #define M_PI_4               0.78539816339744830962
  85. ! #define M_1_PI               0.31830988618379067154
  86. ! #define M_2_PI               0.63661977236758134308
  87. ! #define M_2_SQRTPI   1.12837916709551257390
  88. ! #define M_SQRT1_2    0.70710678118654752440
  89.   
  90.   #endif /* __STRICT_ANSI__ */
  91.   
  92. ***************
  93. *** 183,188 ****
  94. --- 189,196 ----
  95.   __EXTERN double ldexp    __PROTO((double, int));
  96.   __EXTERN double frexp    __PROTO((double, int *));
  97.   #endif /* !_M68881 */
  98. + #endif /* __TURBOC__ */
  99.   
  100.   #ifdef __cplusplus
  101.   }
  102. ===================================================================
  103. RCS file: /net/acae127/home/bammi/etc/src/master/atari/pml/pmlsrc/sqrt.c,v
  104. retrieving revision 1.8
  105. diff -c -r1.8 sqrt.c
  106. *** 1.8    1992/02/03 20:19:23
  107. --- sqrt.c    1992/12/28 08:11:53
  108. ***************
  109. *** 17,23 ****
  110.    ************************************************************************
  111.    */
  112.   
  113.   /*
  114.    *  FUNCTION
  115.    *
  116. --- 17,23 ----
  117.    ************************************************************************
  118.    */
  119.   
  120.   /*
  121.    *  FUNCTION
  122.    *
  123. ***************
  124. *** 116,141 ****
  125.    *    machine I tried.
  126.    *
  127.    */
  128. !  
  129.   /*
  130.    *  MODIFICATIONS
  131.    *
  132. !  *    This routine modified to use polynomial, instead of rational,
  133. !  *    approximation with coefficients
  134. !  *
  135. !  *        P0  0.22906994529e+00
  136. !  *        P1  0.13006690496e+01
  137. !  *        P2 -0.90932104982e+00
  138. !  *        P3  0.50104207633e+00
  139. !  *        P4 -0.12146838249e+00
  140. !  *
  141. !  *    as given by Hart (op. cit.) in SQRT 0132.  This approximation
  142. !  *    gives around 5 digits correct.  Two applications of Heron's
  143. !  *    approximation will give more then practically achievable
  144. !  *    13-15 decimal digits.  Multiplications by powers of 2 are
  145. !  *    replaced by explicit calls to ldexp.
  146.    *
  147. !  *    Michal Jaegermann, 24 October 1990
  148.    */
  149.   
  150.   #if !defined (__M68881__) && !defined (sfp004)
  151. --- 116,146 ----
  152.    *    machine I tried.
  153.    *
  154.    */
  155.   /*
  156.    *  MODIFICATIONS
  157.    *
  158. !  *    Function sqrt(x) is initially approximated on an
  159. !  *      interval [0.5..2.0] by a quadratic polynomial with
  160. !  *    the following coefficients
  161. !  *
  162. !  *         P0  0.3608580479718948e+00
  163. !  *         P1  0.7477707028388739e+00
  164. !  *         P2 -0.1105464728191369e+00
  165. !  *
  166. !  *    These coefficients were computed with a help of Maple
  167. !  *    symbolic algebra system.  Longer approximation interval
  168. !  *    is used in order to avoid multiplication by SQRT2
  169. !  *    constant in case of odd exponents (this idea comes from
  170. !  *    Olaf Flebbe, flebbe@tat.physik.uni-tuebingen.de).  With
  171. !  *    64 bit IEEE representation three Heron's iterations are
  172. !  *    good enough to satisfy essential requirements of Paranoia
  173. !  *    test suite. An absolute error after three iterations is
  174. !  *    below 2e-19 over the whole range (below 5e-10 after two).
  175. !  *    Multiplications by powers of 2 are performed by explicit
  176. !  *    calls to ldexp.
  177.    *
  178. !  *    Michal Jaegermann, 21 October 1992
  179.    */
  180.   
  181.   #if !defined (__M68881__) && !defined (sfp004)
  182. ***************
  183. *** 144,164 ****
  184.   #include <math.h>
  185.   #include "pml.h"
  186.   
  187. ! #ifdef OLD
  188. ! #define P0 0.594604482            /* Approximation coeff    */
  189. ! #define P1 2.54164041            /* Approximation coeff    */
  190. ! #define Q0 2.13725758            /* Approximation coeff    */
  191. ! #define Q1 1.0                /* Approximation coeff    */
  192. ! #define ITERATIONS 3            /* Number of iterations    */
  193. ! #endif
  194. ! #define P0  0.22906994529e+00        /* Hart SQRT 0132 */
  195. ! #define P1  0.13006690496e+01
  196. ! #define P2 -0.90932104982e+00
  197. ! #define P3  0.50104207633e+00
  198. ! #define P4 -0.12146838249e+00
  199.   
  200.   static char funcname[] = "sqrt";
  201.   
  202. --- 149,157 ----
  203.   #include <math.h>
  204.   #include "pml.h"
  205.   
  206. ! #define P0  0.3608580479718948e+00
  207. ! #define P1  0.7477707028388739e+00
  208. ! #define P2 -0.1105464728191369e+00
  209.   
  210.   static char funcname[] = "sqrt";
  211.   
  212. ***************
  213. *** 165,183 ****
  214.   double sqrt (x)
  215.   double x;
  216.   {
  217. - #ifdef OLD
  218.       int k;
  219. -     register int bugfix;
  220. -     register int kmod2;
  221. -     register int count;
  222. -     int exponent;
  223. -     double y;
  224. - #else
  225. -     int k;
  226. - #endif
  227.       double m;
  228.       double u;
  229.       struct exception xcpt;
  230.   
  231.       if (x == 0.0) {
  232.       xcpt.retval = 0.0;
  233. --- 158,168 ----
  234.   double sqrt (x)
  235.   double x;
  236.   {
  237.       int k;
  238.       double m;
  239.       double u;
  240.       struct exception xcpt;
  241. +     register double (*dfunc)(double, int) = ldexp;
  242.   
  243.       if (x == 0.0) {
  244.       xcpt.retval = 0.0;
  245. ***************
  246. *** 192,222 ****
  247.       }
  248.       } else {
  249.       m = frexp (x, &k);
  250. - #ifdef OLD
  251. -     u = (P0 + (P1 * m)) / (Q0 + (Q1 * m));
  252. -     for (count = 0, y = u; count < ITERATIONS; count++) {
  253. -         y = 0.5 * (y + (m / y));
  254. -     }
  255. -     if ((kmod2 = (k % 2)) < 0) {
  256. -         y /= SQRT2;
  257. -     } else if (kmod2 > 0) {
  258. -         y *= SQRT2;
  259. -     }
  260. -     bugfix = 2;
  261. -     xcpt.retval = ldexp (y, k/bugfix);
  262. - #else
  263. -     u = (((P4 * m + P3) * m + P2) * m + P1) * m + P0;
  264. -     u = ldexp((u + (m / u)), -1);    /* Heron's iteration */
  265. -     u += m / u;            /* and a part of the second one */
  266.       if (k & 1) {
  267. !         u *= SQRT2;
  268.       }
  269.       /*
  270.        * here we rely on the fact that -3/2 and (-3 >> 1)
  271. !      * do give different results
  272.        */
  273. !     xcpt.retval = ldexp (u, (k >> 1) - 1);
  274. ! #endif
  275.       }
  276.       return (xcpt.retval);
  277.   }
  278. --- 177,206 ----
  279.       }
  280.       } else {
  281.       m = frexp (x, &k);
  282.       if (k & 1) {
  283. !         m = dfunc(m, 1);
  284. !         /*
  285. !          * multiply by 2 if our exponent was odd;
  286. !          * odd k is now too big by 1 but (k >> 1) will take
  287. !          * care of that
  288. !          */
  289.       }
  290. +     u = (P2 * m + P1) * m + P0;    /* the first guess   */
  291. +     u = dfunc((u + (m / u)), -1);    /* Heron's iteration */
  292. + #ifndef __SOZOBON__
  293. +     /*
  294. +      * with current floating point representation used
  295. +      * by Sozobon C we are already below achievable precision
  296. +      */
  297. +      u = dfunc((u + (m / u)), -1);   /* one more          */
  298. + #endif /* __SOZOBON__ */
  299.       /*
  300.        * here we rely on the fact that -3/2 and (-3 >> 1)
  301. !      * do give different results;
  302. !      * the last iteration and adjust final exponent properly
  303.        */
  304. !     xcpt.retval = dfunc (u + (m / u), (k >> 1) - 1);
  305.       }
  306.       return (xcpt.retval);
  307.   }
  308.